import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'
import { AuthProvider } from './contexts/AuthContext'
import ProtectedRoute from './components/ProtectedRoute'

// 用户端页面
import UserHomeV2 from './pages/user/UserHomeV2'
import GeometryModelView from './pages/GeometryModelView'

// 管理端页面
import AdminLogin from './pages/admin/AdminLogin'
import AdminHomeV2 from './pages/admin/AdminHomeV2'
import GeometryWorkspace from './pages/GeometryWorkspace'

import './App.css'

function App() {
  return (
    <AuthProvider>
      <Router basename="/geometry">
        <Routes>
          {/* 用户端路由 */}
          <Route path="/" element={<UserHomeV2 />} />
          <Route path="/model/:id" element={<GeometryModelView />} />

          {/* 管理端登录 */}
          <Route path="/admin/login" element={<AdminLogin />} />

              {/* 管理端路由（需要认证） */}
              <Route path="/admin" element={
                <ProtectedRoute>
                  <AdminHomeV2 />
                </ProtectedRoute>
              } />
          <Route path="/admin/workspace" element={
            <ProtectedRoute>
              <GeometryWorkspace />
            </ProtectedRoute>
          } />
          <Route path="/admin/workspace/:id" element={
            <ProtectedRoute>
              <GeometryWorkspace />
            </ProtectedRoute>
          } />
        </Routes>
      </Router>
    </AuthProvider>
  )
}

export default App